6.3 How to make a dropdown nenu

  1. Motivations

  2. Read all in How to Create a Dropdown Menu in HTML and CSS.
  3. How to convert the next nested list to a dropdown menu?
    There are three levels in this example. The first level - Home, About, Courses. The second level - E.g., Courses: Web Design & Development, Advanced Web Programming, and Web-based Information System. The third level - E.g., Advanced Web Programming: 'JavaScript, jQuery, Bootstrap', PHP, MySQL, .MVC, SPA'.
    • Home
    • About
    • Courses
      • Web Design & Development
        • HTML
        • CSS
        • JavaScript
      • Advanced Web Programming
        • JavaScript, jQuey, Bootstrap
        • PHP
        • MySQL
        • MVC, SPA
      • Web-based Information System
    • Contact
  4. Here is an example dropdown menu for the above list items.
    • The first level menu items are displayed in a line.
    • The second level menu items are displayed right below their first level menu item.
    • The third level menu items are displayed at the right side of their second level menu item.
    • Home
    • About
    • Courses
      • Web Design & Development
        • HTML
        • CSS
        • JavaScript
      • Advanced Web Programming
        • JavaScript, jQuey, Bootstrap
        • PHP
        • MySQL
        • MVC, SPA
      • Web-based Information System
    • Contact
  5. How to make the above dropdown menu? a) Let's start by wrapping the menu lists within a div element. b) Make the first level items inline elements so that they can be displayed in the same line. c) Make the background color change when the mouse moves over each item. d) Make the 2nd level items not be displayed.
    • Home
    • About
    • Courses
      • Web Design & Development
        • HTML
        • CSS
        • JavaScript
      • Advanced Web Programming
      • Web-based Information System
    • Contact
  6. Trial 1: Let's make the first level menu items 'inline'. Let's also make the 2nd level and the 3rd level menu items not displayed. Let's also delete all the bullets. Can you put some space between menu items? Can you give background-color? Different background-color when the mouse hovers.


  7. Let's make the 2nd level items be displayed when its first level item is hovered.
    • Home
    • About
    • Courses
      • Web Design & Development
        • HTML
        • CSS
        • JavaScript
      • Advanced Web Programming
      • Web-based Information System
    • Contact
  8. Trial 2: Let's try the above exercise. The 2nd level menu should be displayed right below the 1st level menu item. How to decide the position of the 2nd level menu? You also need to delete the bullets.


  9. a) Make the background color of the 2nd level item change when the mouse moves over each item. b) Make the 3rd level items not be displayed.
    • Home
    • About
    • Courses
      • Web Design & Development
        • HTML
        • CSS
        • JavaScript
      • Advanced Web Programming
      • Web-based Information System
    • Contact
  10. Trial 3: Let's give background-color. Different background-color when the mouse hovers.


  11. Make the 3rd level items be displayed when the mouse moves over a 2nd level item. Make the background color of the 3rd level item change when the mouse moves over each item.
    • Home
    • About
    • Courses
      • Web Design & Development
        • HTML
        • CSS
        • JavaScript
      • Advanced Web Programming
      • Web-based Information System
    • Contact
  12. Trial 4: Let's try the above exercise. The 3rd level menu must be displayed at the exact right side of the 2nd menu item.


  13. Can you convert the next nested list to a dropdown menu?
    • COMP2680
    • COMP3540
      • JavaScript
      • PHP
      • MySQL
    • COMP4620
      • JavaScript
      • MongoDB
      • Advanced Topics
  14. Lab 7.

  15. Learning outcomes